/*
 * StaticDrawController.h
 *
 *  Created on: Nov 21, 2011
 *      Author: rudi
 */

#ifndef STATICDRAWCONTROLLER_H_
#define STATICDRAWCONTROLLER_H_
#include "WxUtils.h"
#include "IDrawController.h"

class MainPanel;

/**
 * This class draws a static picture to the window
 *
 * @see IDrawController
 * @author Rudolf Heszele heszele@gmail.com
 * @version 1.0
 * @since 2012-03-08
 */
class StaticDrawController: public IDrawController
{
	public:
		/**
		 * The only constructor takes the bitmap to be painted
		 *
		 * @param bitmap The bitmap to be painted
		 * @param refresh if it is true, the wxWidgets will be forced to do a refresh
		 */
		StaticDrawController(SmartPointer<wxBitmap> bitmap, bool refresh = true);
		virtual ~StaticDrawController();

		// Methods inherited from Controller

		/**
		 * @see IController::handleMouseDown
		 */
		virtual void handleMouseDown(const wxPoint&);
		/**
		 * @see IController::handleMouseUp
		 */
		virtual void handleMouseUp(const wxPoint&);
		/**
		 * @see IController::handleMouseMotion
		 */
		virtual bool handleMouseMotion(const wxPoint&);
		/**
		 * @see IController::getBitmapToPaint
		 */
		virtual const wxBitmap& getBitmapToPaint() const;
		/**
		 * @see IController::getBitmapToDraw
		 */
		virtual wxBitmap& getBitmapToDraw();

		// Methods inherited from IDrawController

		/**
		 * @see IDrawController::getActualVehicle
		 */
		virtual SmartPointer<Vehicle> getActualVehicle() const;
		/**
		 * @see IDrawController::getRemoteVehicle
		 */
		virtual SmartPointer<Vehicle> getRemoteVehicle() const;
		/**
		 * @see IDrawController::getActualVehicleArrows
		 */
		virtual SmartPointer<std::vector<wxPoint> > getActualVehicleArrows();
		/**
		 * @see IDrawController::getRemoteVehicleArrows
		 */
		virtual SmartPointer<std::vector<wxPoint> > getRemoteVehicleArrows();
		/**
		 * This method paints the dots to the picture, and optionally makes a refresh
		 *
		 * @param doRefresh If true wxWidgets will be forced to do a refresh
		 * @param mainPanel The MainPanel to do the refresh on
		 */
		void refreshImage(bool doRefresh = true, MainPanel* mainPanel = NULL);

		// Own methods

		void setBitmap(SmartPointer<wxBitmap> bitmap);

	protected:
		/**
		 * Paints the dots to the bitmap
		 */
		void paintDots();
		/**
		 * Sets the pen with the given color and width
		 *
		 * @dc The device context to set the pen in
		 * @color The requested color of the pen
		 * @width The requested width of the pen
		 */
		void setPen(wxDC& dc, const WxUtils::Color& color, int width = 1) const;

		SmartPointer<wxBitmap> mBitmap;
};

inline void StaticDrawController::setBitmap(SmartPointer<wxBitmap> bitmap)
{
	mBitmap = bitmap;
}

#endif /* STATICDRAWCONTROLLER_H_ */
